package com.itheima.comfyui.core.controller;

import com.itheima.comfyui.core.dto.common.Result;
import com.itheima.comfyui.core.dto.request.UserLoginReqDTO;
import com.itheima.comfyui.core.dto.respone.UserLoginResDTO;
import com.itheima.comfyui.core.service.IUserService;
import org.apache.coyote.BadRequestException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/1.0/user")
public class UserController {
    @Autowired
    private IUserService userService;

    /**
     * 用户登录
     * @param reqDTO
     * @return
     */
    @PostMapping("/login")
    public Result<UserLoginResDTO> login(@RequestBody UserLoginReqDTO reqDTO) throws BadRequestException {
        UserLoginResDTO result = userService.login(reqDTO);
        return  Result.ok(result);
    }
}
